import React from 'react'
import {Input,Button,List} from "antd";
import store from "../store/store";


export default class SearchList extends React.Component{
    constructor() {
        super();
        const storeState = store.getState()
        console.log(storeState)
        this.state = {
            ...storeState
        }

        store.subscribe(()=>{
            const storeState1 = store.getState()
            console.log(storeState1)
            this.setState({
                ...storeState1
            })
        })
    }
    handleChange(e){
        console.log(e.currentTarget.value)
        const  action = {
            type:"changeValue",
            value:e.currentTarget.value
        }
        store.dispatch(action)

    }
    render() {
        const data = [
            'Racing car sprays burning fuel into crowd.',
            'Japanese princess to wed commoner.',
            'Australian walks 100km after outback crash.',
            'Man charged over missing wedding girl.',
            'Los Angeles battles huge wildfires.',
        ];
        return (
            <div className="search-list">
                {this.state.name}
                <div>
                    <Input placeholder="Basic usage" value={this.state.value} onChange={this.handleChange}/>
                    <Button type="primary">发送</Button>
                </div>
                <div>
                    <List
                        size="small"
                        header={<div>Header</div>}
                        footer={<div>Footer</div>}
                        bordered
                        dataSource={data}
                        renderItem={item => <List.Item>{item}</List.Item>}
                    />
                </div>
            </div>
        )
    }
};
